package com.whm.hrmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whm.common.annotation.Log;
import com.whm.common.core.controller.BaseController;
import com.whm.common.core.domain.AjaxResult;
import com.whm.common.enums.BusinessType;
import com.whm.hrmanagement.domain.OaTargetTracking;
import com.whm.hrmanagement.service.IOaTargetTrackingService;
import com.whm.common.utils.poi.ExcelUtil;
import com.whm.common.core.page.TableDataInfo;

/**
 * 个人计划表Controller
 * 
 * @author whm
 * @date 2024-02-13
 */
@RestController
@RequestMapping("/hrmanagement/tracking")
public class OaTargetTrackingController extends BaseController
{
    @Autowired
    private IOaTargetTrackingService oaTargetTrackingService;

    /**
     * 查询个人计划表列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaTargetTracking oaTargetTracking)
    {
//        startPage();
        List<OaTargetTracking> list = oaTargetTrackingService.selectOaTargetTrackingList(oaTargetTracking);
        return getDataTable(list);
    }

    /**
     * 导出个人计划表列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:export')")
    @Log(title = "个人计划表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaTargetTracking oaTargetTracking)
    {
        List<OaTargetTracking> list = oaTargetTrackingService.selectOaTargetTrackingList(oaTargetTracking);
        ExcelUtil<OaTargetTracking> util = new ExcelUtil<OaTargetTracking>(OaTargetTracking.class);
        util.exportExcel(response, list, "个人计划表数据");
    }

    /**
     * 获取个人计划表详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oaTargetTrackingService.selectOaTargetTrackingById(id));
    }

    /**
     * 新增个人计划表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:add')")
    @Log(title = "个人计划表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaTargetTracking oaTargetTracking)
    {
        return toAjax(oaTargetTrackingService.insertOaTargetTracking(oaTargetTracking));
    }

    /**
     * 修改个人计划表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:edit')")
    @Log(title = "个人计划表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaTargetTracking oaTargetTracking)
    {
        return toAjax(oaTargetTrackingService.updateOaTargetTracking(oaTargetTracking));
    }

    /**
     * 删除个人计划表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:tracking:remove')")
    @Log(title = "个人计划表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oaTargetTrackingService.deleteOaTargetTrackingByIds(ids));
    }
}
